import { useThemeStore } from '@/stores/theme'
import { useAppStore } from '@/stores/app'

export default {
    computed: {
        $theme() {
            // 延迟调用 store，确保 Pinia 已初始化
            try {
                const themeStore = useThemeStore()
                const appStore = useAppStore()
                return {
                    primaryColor: themeStore?.primaryColor || '#FF2C3C',
                    pageStyle: themeStore?.vars || '',
                    navColor: themeStore?.navColor || '#000000',
                    navBgColor: themeStore?.navBgColor || '#ffffff',
                    variable: themeStore?.vars || ''
                    // title: appStore.getWebsiteConfig.shop_name
                }
            } catch (e) {
                // 如果 store 未初始化，返回默认值
                console.log('theme mixin: store not ready', e)
                return {
                    primaryColor: '#FF2C3C',
                    pageStyle: '',
                    navColor: '#000000',
                    navBgColor: '#ffffff',
                    variable: ''
                }
            }
        }
    }
}
